<template>
  <div class="breadcrumb-group" v-if="showFlag">
    <a-breadcrumb>
      <a-breadcrumb-item v-for="item in  breadcrumbList">{{item}}</a-breadcrumb-item>
    </a-breadcrumb>
  </div>
  <div v-else class="null-class"></div>
</template>
<script>
import commonJS from "@/utils/commonJS";
export default {
  name: 'Breadcrumb',
  data () {
    return {
      // breadcrumbData: this.$route
    }
  },
  computed: {
    breadcrumbList: function () {
      let path = this.$route.path
      let menuList = this.$store.getters.MENULIST
      let menus = commonJS.formatPingData(menuList)
      let b = this.getPathName(menus, path)
      return b
    },
    showFlag : function () {
      let userType = this.$store.getters.USERTYPE
      let path = this.$route.path
      if (userType == '0' && path == '/home') {
        return false
      }
      return true
    }
  },
  methods:{
    getPathName (menus, path){
      let arr = []
      const _loop = (menus, pid) => {
        let result = menus.filter(item => item.id == pid)
        if (result.length > 0) {
          arr.push(result[0].menuName)
          if (!!result[0].id) {
            _loop(menus, result[0].pid)
          }
        }
      }
      let result = menus.filter(item => item.menuPath == path)
      if (result.length > 0) {
        arr.push(result[0].menuName)
        if (!!result[0].id) {
          _loop(menus, result[0].pid)
        }
      }
      arr = arr.reverse()
      return arr
    }
  },
  mounted () {
  }
}
</script>

<style lang="less" scoped>
.null-class {
  height: 15px
}

.breadcrumb-group {
  margin-top: -8px;
  height: 54px;
  padding: 16px 0;
  // height: 46px;
  // padding: 8px 0 16px 0;
  // line-height: ;
  //margin-bottom: 15px;
  span {
    font-size: 14px;
    color: rgba(27,30,34,0.45);
    line-height: 24px;
    font-weight: 400;
  }
  div>span:last-child {
    font-size: 14px;
    color: rgba(27,30,34,0.85);
    line-height: 22px;
    font-weight: 400;
  }

}

</style>
